import axios from 'axios';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';

//创建实例
const instance = axios.create({
  baseURL: 'http://127.0.0.1:3002',
  method: 'get',
  timeout: 3000
});

//设置拦截器
instance.interceptors.request.use(config => {
  NProgress.start();
  return config;
})

instance.interceptors.response.use(response => {
  NProgress.done();
  return response.data;
}, error => {
  console.log('请求异常, 请稍后再试~ ', error);
  return Promise.reject(error);
})

export default instance;